<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
	<title>Catalog</title>
</head>
<body>
<body background="../img/bg.jpg"> 
	<font face="Berlin Sans FB Demi" color="#357EC7" size="3">
<center>
<br><br><br><br>
<h1>Motivare absente</h1>
	<?
error_reporting (E_ALL ^ E_NOTICE);
include('auth.php');
include('../config.php');
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$link) {die('Failed to connect to server: ' . mysql_error());}
           
$db = mysql_select_db(DB_DATABASE);
if(!$db) {die("Unable to select database");}
?>
<b>

<form action='' method="post">
<table border="1">
<tr><td>Elev: </td><td><b><? $elev=$_GET['elev']; $r=mysql_fetch_array(mysql_query("select nume from elev where id='".$elev."'")); echo $r[0]; ?></b></td></tr>
<tr><td>Materie: </td><td><b><? $materie=$_GET['materie']; $r=mysql_fetch_array(mysql_query("select nume from materie where id='".$materie."'")); echo $r[0];?></b></td></tr>
<tr><td>Absenta nemotivata </td><td><select name="abs">
<?


$abs1=explode('-',$abs);
$select=mysql_query("select * from elev_has_materie where elev_id='".$elev."' and materie_id='".$materie."'");
$i=0;
$j=0;
while ($result=mysql_fetch_array($select)) {
$abs1=explode('-',$result['abs']);
if ($abs1[1]=="nemotivata" or $abs1[1]=="NEMOTIVATA") {
echo "<option>".$abs1[0]."</option>";
}
}
?>

</select>
</td></tr>

<tr><td colspan="2"><center><input type="submit" value="OK" name="ok"></center></tr></td>
</form>
<?
function clean($str) {
		$str = @trim($str);
		if(get_magic_quotes_gpc()) {
			$str = stripslashes($str);
		}
		return mysql_real_escape_string($str);
	}
if(isset($_POST['ok'])) {
$abs=$_POST['abs'];


$absn="$abs-motivata";
if ($absn!='') {
$sql2=mysql_query("update elev_has_materie set abs='".$absn."' where elev_id='".$elev."' and materie_id='".$materie."'");
}
header('location: clasa.php');
}


?>
</font>
</center>
</body>
</html>